package Example;
//输出一个数的各个位数

import java.util.Scanner;

public class Demo1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入一个九位数之内的整数：");//int最高21亿
        int  a = scan.nextInt();
        int num;
        int i = 1;
        String c;
        while (a != 0) {
            switch (i){
                case 1:c = "个";break;
                case 2:c = "十";break;
                case 3:c = "百";break;
                case 4:c = "千";break;
                case 5:c = "万";break;
                case 6:c = "十万";break;
                case 7:c = "百万";break;
                case 8:c = "千万";break;
                case 9:c = "亿";break;
                default:
                    throw new IllegalStateException("Unexpected value: " + i);
            }
            num = a % 10; //获取每一位
            a = a / 10;    //整数退一位
            System.out.println(c+"位数为"+num);
            i++;
        }
    }
}